import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';

//提示
export default async function (fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	// 调用事件
	const type = args[0];
	// success成功---绿
	// fail失败---红
	// cancel取消---取消
	// please请---黄
	const info = args[1];
	const success_div = fd.data.node.querySelector('[data-feidao-id="success_div"]') as HTMLElement;//成功
	const fail_div = fd.data.node.querySelector('[data-feidao-id="fail_div"]') as HTMLElement;//失败
	const cancel_div = fd.data.node.querySelector('[data-feidao-id="cancel_div"]') as HTMLElement;//取消
	const please_div = fd.data.node.querySelector('[data-feidao-id="please_div"]') as HTMLElement;//请
	const d_div = fd.data.node.querySelector('[data-feidao-id="d_div"]');
	if (type == 'success') {
		d_div.classList.remove('display-n');
		const prompt_sucess = fd.data.node.querySelector('[data-feidao-id="prompt_sucess"]') as HTMLElement;
		prompt_sucess.innerHTML = info;
		success_div.classList.remove('display-n');
	} else if (type == 'fail') {
		d_div.classList.remove('display-n');
		const prompt_fail = fd.data.node.querySelector('[data-feidao-id="prompt_fail"]') as HTMLElement;
		prompt_fail.innerHTML = info;
		fail_div.classList.remove('display-n');
	} else if (type == 'cancel') {
		d_div.classList.remove('display-n');
		const prompt_cancel = fd.data.node.querySelector('[data-feidao-id="prompt_cancel"]') as HTMLElement;
		prompt_cancel.innerHTML = info;
		cancel_div.classList.remove('display-n');
	} else if (type == 'please') {
		d_div.classList.remove('display-n');
		const prompt_please = fd.data.node.querySelector('[data-feidao-id="prompt_please"]') as HTMLElement;
		prompt_please.innerHTML = info;
		please_div.classList.remove('display-n');
	};

	fd.data.node.classList.remove('display-n');

	const d = window.setTimeout(() => {
		window.clearTimeout(d);
		success_div.classList.add('display-n');
		cancel_div.classList.add('display-n');
		please_div.classList.add('display-n');
		fail_div.classList.add('display-n');
		d_div.classList.add('display-n');
	}, 1000);
}
